import axios from 'axios'
const request = axios.create({
  baseURL: 'http://api.ecook.cn/',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
})
request.interceptors.request.use(function (config) {
  // 在发送请求之前做些什么
  if (config.method === 'post') {
    let stringParams = ''
    for (let key in config.data) {
      stringParams += `${key}=${config.data[key]}&`
    }
    stringParams = stringParams.slice(0, -1)
    config.data = stringParams
  }
  return config
})
export default request
